#!/usr/bin/env python
# encoding: utf-8
'''
@author: zhaowenpeng
@contact: winston@peipeiyun.com
@software: garner
@file: fetch_code_oe.py
@time: 2020/8/11 2:44 下午
@desc:
'''



import os
import pandas as pd
import numpy

import time


from models.parts import Parts
file = "/Users/carl/Desktop/007vin/data/chang01.csv"
df = pd.read_csv(file)
df.fillna('',inplace=True)
# df['input_oe'] = df['input_oe'].astype('str')
for index, row in df.iterrows():
    print(row.to_dict())
    code = row.to_dict()['code']
    part = Parts.get_or_none(Parts.code==code)
    if not part.remark:
        part.standard_name = row.to_dict()['standard_name']
        part.corr_oe = row.to_dict()['corr_oe']
        part.brand_code = row.to_dict()['brand_code']
        part.is_exist = row.to_dict()['is_exist']
        part.origin_name = row.to_dict()['origin_name']
        part.sale_cars_count = row.to_dict()['sale_cars_count'] or 0
        part.save()